package com.project.myproject.entity;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.*;

/**
 * @author Honorable(mabingqian)
 * @description
 * @date 2020/8/5 20:09
 * @update （更新、优化，注明点）
 */
public class Search {

    public static void main(String[] args) {
        String path="C:\\Users\\mabingqian\\Desktop\\BOOT-INF\\lib";
        getFiles(path);

        Map<String, Long> status = new HashMap<>();
        status.put("200", 100L);
        status.put("401", 50L);
        status.put("500", 30L);

        Set<String> strings = status.keySet();
        for (String statu : strings) {
            Long num = status.get(statu);
            System.out.println("返回码：" + statu + ", 数量：" + num);
        }

    }

    public static void getFiles(String path) {
        File file = new File(path);
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    System.out.println("目录：" + files[i].getPath());
                    getFiles(files[i].getPath());
                } else {
                    String name = files[i].getName();
                    String[] split = name.split("-");
                    StringBuilder stringBuilder = new StringBuilder();
                    int len = split.length;
                    for (int j = 0; j < len - 1; j++) {
                        stringBuilder.append(split[j]).append("-");
                    }
                    stringBuilder.deleteCharAt(stringBuilder.length()-1);
                    String s = split[len - 1];
//                    System.out.println("依赖：" + stringBuilder.toString() + " 版本号: " + s.substring(0, s.length() - 4));
//                    System.out.println(stringBuilder.toString());
                    System.out.println(s.substring(0, s.length() - 4));
                }
            }
        } else {
            System.out.println("目录：" + file.getPath());
        }
    }

}
